<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<body>
本程序基于github的<a href="https://github.com/benburkhart1/ipv6-subnet-calculator" target="_blank">ipv6-subnet-calculator</a>二次开发 ， ↑ 改改参数肯定可以实现您的功能<br>
您的IP地址是 <span style="color:red"><?php  $ip = $_SERVER['REMOTE_ADDR']; echo $ip; ?></span>
<?php
    if( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ){
        echo "<span style='color:red;'>您的网络<b>或</b>终端仅支持IPV4，并不支持IPV6或者未以IPV6方式访问本站！</span><br>";
    }else if(filter_var($ip, FILTER_VALIDATE_IP)){
        echo "<span style='color:green;'>恭喜,您的网络<b>和</b>终端已正常支持IPV6！</span><br>";
    }
?>
以下是几个参数示例：<br>
<a href="?address=2409:876c:220::&len=48&len2=52">将2409:876c:220::/48划分为52位子网 ?address=2409:876c:220::&len=48&len2=52</a><br>
<a href="?address=2409:876c:220::&len=48&len2=54">将2409:876c:220::/48划分为54位子网 ?address=2409:876c:220::&len=48&len2=54</a><br>
<a href="?address=2409:876c:220::&len=48&len2=56">将2409:876c:220::/48划分为56位子网 ?address=2409:876c:220::&len=48&len2=56</a><br>
<a href="?address=2409:876c:220::&len=48&len2=60">将2409:876c:220::/48划分为60位子网 ?address=2409:876c:220::&len=48&len2=60</a><br>
<a href="?address=2409:876c:220::&len=52&len2=61">将2409:876c:220::/52划分为61位子网 ?address=2409:876c:220::&len=52&len2=61</a><br>
<a href="?address=2409:876c:210::/52&len2=60">将2409:876c:220::/52划分为60位子网 ?address=2409:876c:210::/52&len2=60</a><br>
<a href="?address=2409:876c:210::/52&len2=64">将2409:876c:220::/52划分为64位子网 ?address=2409:876c:210::/52&len2=64</a><br>
<pre>
<?php
require_once 'IPV6SubnetCalculator.php';

if( isset($_GET['address']) )
{
    $address = substr(trim($_GET['address']) , 0, 50);
    $address_a = explode( "/" , trim($_GET['address']));
    $address = $address_a[0];
}else{
	$address = "2409:876c:220::"; 
}

if( isset($_GET['len']) )
{
    //参数中的掩码优先级更高
	$len     = intval($_GET['len']);
}else{
    if(isset($address_a[1])){
        $len = intval($address_a[1]);
    }else{
        $len = 48;
    }
}

if( isset($_GET['len2']) )
{
    $len2     = intval($_GET['len2']);
}else{
    $len2     = 56;
}

//echo "address:{$address}\nlen:{$len}\n\en2:{$len2}\n";

$calc = new IPV6SubnetCalculator();

if ($calc->testValidAddress($address))
{
    if($len2 - $len > 16){
        exit("所转换的子网数量过大！");
    }
	$rangedata = $calc->getAddressRange($address, $len);
    $subnet_data = $calc->splitAddress($address , $len , $len2 , true);
    echo "输入的子网信息如下：".print_r($rangedata,true);
    echo "拆分后子网信息如下：".print_r($subnet_data,true);
}
?>
</pre>
</body>